package com.yangff.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

import java.util.concurrent.Executor;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

@Configuration
public class ThreadPoolConfig {
    private static final int CORE_SIZE = 16;
    @Bean
    public Executor threadPoolExecutor()
    {
        return new ThreadPoolExecutor(CORE_SIZE,
                CORE_SIZE*2 + 1,
                60,
                TimeUnit.SECONDS ,
                new LinkedBlockingQueue<>(),
                r -> new Thread(r,"fts-thread-" + Thread.currentThread().getName()),
                new ThreadPoolExecutor.AbortPolicy());
    }


}
